
<html>

	<head>
            <link rel="stylesheet" type="text/css" href="scripts/prueba.css"/>
	</head>

	<body>
		<div class="pcpal">
		<div class="menu">
                <?php
                    require_once("scripts/Menu.php");
                ?>
                </div>
                <div class="content1">
                    <img src="/AppResiduos2/images/6331428.jpg" alt="energia" style="width: 800px; height: 330px;" align="middle">
                </div>
                <div class="content2">

                <?php

                require_once("/var/www/AppResiduos2/lib/dao/EmpresaDAO.php");
                require_once("/var/www/AppResiduos2/lib/dao/TransportadorResiduoDAO.php");

                session_start();
		$privil = $_SESSION['priv'];
                $idResidue = $_GET['idResidue'];
                $idproducer = $_GET['idproducer'];
                $quantity = $_GET['quantity'];

                $eDAO = new EmpresaDAO();
                $e = new Empresa();
                /* Se obtienen las cantidades transportadas de residuos y sus
                respectivos transportadores */
                $trDAO = new TransportadorResiduoDAO();
                $tr = $trDAO->listarCantidades($idResidue, $idproducer);
                // La cantidad disponible (aun sin transportar)
                $tr2 = $trDAO->listarCantRestante2($idResidue, $idproducer);

                ?>

                <table id="others" border="1">
				<tr class="alt2">
					<td> Transporter's id </td>
					<td> Transporter's name  </td>
                                        <td> Transported quantity </td>
                                        <td> Available quantity </td>
                                        <td></td>
                                        <td></td>
				</tr>
		<?php
                                        $i = 0;
					while ($i < sizeof($tr))
					{

                ?>				<tr class="alt2">
							<td> <?php print_r($tr[$i]->idtransp); ?> </td>
							<td> 
                                                        <?php
                                                            $e = $eDAO->obtenerEmpresa($tr[$i]->idtransp);
                                                            print_r($e[0]->name);
                                                        ?>
                                                        </td>
                                                        <td> <?php print_r($tr[$i]->quantity); ?> </td>
                                                        <td> <?php print_r($tr2); ?> </td>
		<?php

						if ($privil == 1)
						{

                ?>
							<td> <form method=post action="AdministrarTranspResiduos.php">
                                                                <input type="hidden" name="id_residue" value="<?php echo $idResidue; ?>">
                                                                <input type="hidden" name="id_producer" value="<?php echo $idproducer; ?>">
								<input type="hidden" name="name_transporter" value="<?php echo $e[0]->name; ?>">
                                                                <input type="hidden" name="quantity_residue" value="<?php echo $tr2; ?>">
								<input type="submit" name="modifyTranspResiduos" value="Modify"> </form> </td>
							<td> <form method=post action="AdministrarTranspResiduos.php">
								<input type="hidden" name="id_residue" value="<?php echo $idResidue; ?>">
                                                                <input type="hidden" name="id_producer" value="<?php echo $idproducer; ?>">
                                                                <input type="hidden" name="name_transporter" value="<?php echo $e[0]->name; ?>">
								<input type="submit" name="deleteTranspResiduos" value="Delete"> </form> </td>

		<?php
						}
                                                $i = $i + 1;
		?>

						</tr>
		<?php
					}
					if ($privil == 1){

		?>
						<tr class="alt2">
                                                    <td colspan="4"></td>
                                                    <td colspan=1> <form method=post action="AdministrarTranspResiduos.php">
                                                            <input type="hidden" name="id_residue" value="<?php echo $idResidue; ?>">
                                                            <input type="hidden" name="id_producer" value="<?php echo $idproducer; ?>">
                                                            <input type="hidden" name="quantity_residue" value="<?php echo $tr2; ?>">
                                                            <input type="submit" name="newTranspResiduos" value="New"> </form> </td>
                                                    <td></td>
						</tr>
		<?php
					}
		?>
		</table>
		</div>
                </div>
	</body>



</html>



